#include "draw.h"

void DrawPoint( float x,float y,DWORD color )
{
	hge->Gfx_RenderLine(x,y,x+1,y+1,color);
}

void DrawLine( float x1, float y1, float x2, float y2, DWORD color )
{
	hge->Gfx_RenderLine( x1, y1, x2, y2, color );
}

void DrawRect( float x, float y, float w, float h, DWORD color, bool bSolid )
{
	if( bSolid )
	{
		for( int i=(int)y; i<y+h; i++ )
			hge->Gfx_RenderLine(x,(float)i,x+w,(float)i,color);
	}
	else
	{
		hge->Gfx_RenderLine( x, y, x+w, y, color );
		hge->Gfx_RenderLine( x, y, x, y+h, color );
		hge->Gfx_RenderLine( x, y+h, x+w, y+h, color );
		hge->Gfx_RenderLine( x+w, y, x+w, y+h, color );
	}
}

void DrawNum( int num, hgeSprite *spr, float x, float y, int aligen )
{
	float draw_x = x,draw_y = y;
	float dw = spr->GetWidth()/10;
	int temp = num;
	int digit = 0;

	while( temp != 0 )
	{
		temp/=10;
		digit++;
	}

	if( aligen == HGETEXT_LEFT )
		draw_x -= dw*digit;
	else if( aligen == HGETEXT_MIDDLE )
		draw_x += dw*digit/2;
	else if( aligen == HGETEXT_RIGHT )
		draw_x -= dw;

	temp = num;
	while( temp != 0 )
	{
		spr->SetTextureRect((temp%10)*dw,0,dw,spr->GetHeight());
		spr->Render(draw_x,draw_y);
		temp/=10;
		draw_x -= dw;
	}
}